<template>
	<div class="p_20 indexBanner">
		<el-dialog :visible.sync="isShow" :close-on-click-modal="false" @close="closeDialog">
			<!-- <el-divider></el-divider> -->
			<el-form :model="form" label-width="80px">
				<UploadImg ref="UploadImg" :upImg="upImg"></UploadImg>

				<el-form-item label="内容">
					<el-input v-model="form.content" class="w_400" type="textarea" :rows="5"></el-input>
					<!-- <span>（请将http://一并填入）</span> -->
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="closeDialog">取 消</el-button>
				<el-button type="primary" @click="submit">确 定</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				isShow: false,
				form: {
					id: '',
					type: '',
					content: '',
					file: ''
				},
				upImg: {
					label: "图片",
					imageUrl: "",
					name: "file",
					width: "260",
					height: "260",
					file: "",
				},

				//图片上传
				imageUrl: "",
				// dialogVisible: false,
				// disabled: false
			};
		},
		methods: {
			//提交
			submit() {
				let params = new FormData();

				params.append('id', this.form.id);
				params.append('type', this.form.type);
				params.append('content', this.form.content);
				params.append('position', this.form.position);
				params.append('language', this.$store.getters.getLanguage);

				if (this.upImg.file) {
					params.append('file', this.upImg.file);
				}

				if (this.form.id) {
					this.edit(params);
				}
			},


			//编辑
			edit(params) {
				this.axiosPostFile("Job/companyEdit", params, (res) => {
					if (res.data.code === 0) {
						this.msgSuccess(res.data.message);
						this.$parent.getTableData();
						this.isShow = false;
					}
				});
			},

			//图片上传
			handleAvatarSuccess(res) {
				console.log(res);
				// console.log(file);
				//图片id
				this.form.image_id = res.data.id;
				//图片url
				this.imageUrl = this.imgURL + res.data.image_url;
				// this.form.url = res.data.image_url;
				// this.dialogVisible = true;
			},

			//关闭窗口 清空数据
			closeDialog() {
				this.form = {
					id: '',
					type: '',
					content: '',
					file: ''
				};
				this.imageUrl = "";
				this.isShow = false;
			},
		},
	};
</script>

<style scoped>
</style>
